package first.codeTop.tencent;

/**
 * @ClassName LC300
 * @description:
 * @author: 荣燊
 * @create: 2021-10-25 10:54
 **/
public class LC300 {
    // 最长递增子序列
    public static void main(String[] args) {
        int[] a = {10, 9, 2, 5, 3, 7, 101, 18};
        System.out.println(lengthOfLIS(a));
     }

    public static int lengthOfLIS(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        int[] dp = new int[nums.length];
        // 初始化都是1
        for (int i=0; i<nums.length; i++) {
            dp[i] = 1;
        }
        // 开始
        int res = 0;
        for (int i=0; i<nums.length; i++) {
            for (int j=0; j<i; j++) {
                if (nums[j] < nums[i]) {
                    dp[i] = Math.max(dp[i], dp[j]+1);
                }
            }
            res = Math.max(res, dp[i]);
        }
        return res;
    }
}
